#{extends 'main.html' /}

#{set title:'Liste des stages' /}

    #{if agent_for.toString() == '4' || agent_for.toString() == '3'}
        <div id="menu_right">
            <p><a href="/stages/gerer/">Liste des stages terminés</a> | <a href="@{Stages.newStageForm}">Créer un stage</a></p>
        </div>
	#{/if}
#{if stages}
    <div class="post">
        <div class="post">
            <h2 class="post-title">
                Liste des stages
            </h2>
            <br>
            <table cellpadding="0" cellspacing="0" border="0" class="display" id="liste"> 
        		<thead>
        			<tr>
        				<th>Intitule</th>	
        				<th>Code</th>
        				<th>Nature</th>
        				<th>Structure Organisatrice</th>
        				<th>Durée</th>
        				<th>Lieu</th>
        				<th>Date de Début</th>
        				<th>Condition de déroulement</th>
        				<th>Date de Fin</th>
        				<th>Date d'évaluation</th>
        				<th>Nombre de place disponible</th>
        				<th>Etat</th>
        				<th></th>	
        				<th></th>		
        			</tr>
        		</thead>		

                <tbody>
        	    #{list items:stages, as:'stage' } 
        	       <tr>
        	            <td> 
                            ${stage.intitule}
        	            </td>
        	            
        	            <td> 
                            ${stage.code}
        	            </td>
        	            
        	            <td> 
                            ${stage.nature}
        	            </td>
        	            
        	            <td> 
                            ${stage.structure}
        	            </td>
        	            
        	            <td> 
                            ${stage.duree} Jour(s)
        	            </td>
        	            
        	                <td> 
                            #{if stage.lieu == null}
                                -
        	                #{/if}
                            #{else}
        	                    ${stage.lieu}
                            #{/else}
        	            </td>
        	            
        	            <td> 
                            #{if stage.dateDeb == null}
                                -
        	                #{/if}
                            #{else}
        	                    ${stage.dateDeb.format('dd MMMM yyyy', 'fr')}
                            #{/else}
        	            </td>
        	            
        	            <td> 
                            #{if stage.modalites == null}
                                -
        	                #{/if}
                            #{else}
        	                    ${stage.modalites}
                            #{/else}
        	            </td>
        	            
        	            
        	            <td> 
                            #{if stage.dateFin == null}
                                -
        	                #{/if}
                            #{else}
        	                    ${stage.dateFin.format('dd MMMM yyyy', 'fr')}
                            #{/else}
        	            </td>
        	            
        	            <td> 
                            #{if stage.dateExam == null}
                                -
        	                #{/if}
                            #{else}
        	                    ${stage.dateExam.format('dd MMMM yyyy', 'fr')}
                            #{/else}
        	            </td>
        	            
        	            <td> 
                            #{if stage.getEffectif() == null}
                                -
        	                #{/if}
                            #{else}
                            #{if !(stage.effectifMax == null)}
        	                    ${(stage.effectifMax)-(stage.getEffectif())}
        	                #{/if}
                            #{/else}
        	            </td>
        	            
        	            <td> 
        	                ${stage.etat}
        	            </td>
        	            <td>
        	                 <a href="@{Stages.detailStage(stage.id)}">Détails</a>
        	            </td>
        	            
        	           <td style="margin-top:30px">    
        	   			 #{form @candidStage(stage.id)}    
        	            #{if (stage.effectifMax == stage.getEffectif())}  
       	 				-		
        	             #{/if} 
        	             #{else} 
        	              #{if (stage.dateDeb>=aujourdhui)} 
        	               
        	              <input type="submit" value="Candidater" />
       	 	
        	             #{/if}   
        	             #{/else}
        	               #{/form}
        	           </td>
        	       </tr>
        	       
        	       
        	    #{/list}
        	    </tbody>
        	</table>
        </div>
    </div>    
#{/if}
 
#{else}
    <div class="empty">
        Pas de stage.
    </div>
#{/else}
